Add region-aware CLI profile support#40
Conversation
Code Review: Region-aware CLI profile supportReviewed the full diff, checked out the branch, and ran build/format/tests locally:
This is a well-structured, well-documented change. Region logic is cleanly centralized in the new Issues1. Dead condition + misleading comment in the region-mismatch guard ( sessionRegion := currentRegionFromContext(ctx)
if bindingRegion != "" && sessionRegion != "" && !strings.EqualFold(bindingRegion, sessionRegion) {The comment says "An empty session region (fresh login default) is treated as 'no opinion' and does not conflict." But Practical consequence: a repo bound to 2. Unrelated changes bundled in — scope creep ( Minor / Nits
Done well
🤖 Generated with Claude Code |
Correction: reset-to-global on
|
…ion guard - Remove GIT_ALLOW_PROTOCOL=file and the conditional --depth skip from the quickstart clone path. Plain `git clone --depth 1 <abs-path>` already works for the local fixture repos (verified against the existing integration tests), so the file-protocol enablement was unnecessary scope. - Drop the dead `sessionRegion != ""` clause in the PROJECT_REGION_MISMATCH guard (currentRegionFromContext never returns empty) and fix the comment to describe the real invariant. - Document in CHANGELOG that bare `agora login` resets the active region to global and clears session-scoped project context. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RepoURLCN / DocsURLCN are byte-identical to their global counterparts today; document that this is intentional scaffolding (no China-hosted mirror yet) so the duplication doesn't read as a copy-paste mistake. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Add region-aware CLI profile support for
globalandcn, so login, API/OAuth endpoints, doctor checks, Console/docs links, quickstart URLs, and project context resolution follow the active login region. This also removes projectregionfields that are not returned by the project APIs and stops persisting API/OAuth integration defaults inconfig.json.Type of change
error.coderename/removal)Public-contract impact
error.code— added todocs/error-codes.md.error.code— flagged as breaking, included in CHANGELOG.docs/automation.md.Contract changes:
auth login --jsonandauth status --jsonnow includedata.region.region, because the project list API does not return that field.config get --jsonno longer returnsapiBaseUrl,oauthBaseUrl,oauthClientId, oroauthScope.config updateremoves the endpoint/OAuth persistence flags:--api-base-url,--oauth-base-url,--oauth-client-id, and--oauth-scope.project createandinitno longer accept--region; they use the active login region.project env writeadds--projectfor explicit project targeting.PROJECT_REGION_MISMATCHerror is returned when a repo-local project binding region conflicts with the active login region.Config migration:
config.jsonschema is bumped to version 4.apiBaseUrl,oauthBaseUrl,oauthClientId, andoauthScopekeys are dropped during migration.AGORA_API_BASE_URL,AGORA_OAUTH_BASE_URL,AGORA_OAUTH_CLIENT_ID, andAGORA_OAUTH_SCOPE.Test plan
go test ./...passes locally.make lintpasses locally (gofmt,golangci-lint, error-code coverage audit).internal/cli/integration_test.go.internal/cli/app_test.go(where applicable).Additional verification run:
go run ./cmd/gendocs -checkgit diff --checkDocumentation
CHANGELOG.mdupdated under## Unreleased(Added / Changed / Deprecated / Removed / Fixed / Security).docs/automation.mdupdated for any user-facing JSON shape, env var, or flag change.docs/error-codes.mdupdated for any newerror.code(or N/A).README.mdupdated if the command tree, install path, or quickstart changed.AGENTS.mdupdated if engineering or release process changed.Security checklist
$HOMEwithout0o600perms when it can contain credentials (e.g. session, config).unsafeimport.Additional notes
Reviewers should pay extra attention to the config migration and region-switching behavior:
PROJECT_REGION_MISMATCHwhen they do not match the active login region.